<template>
  <el-dialog :title="!themeid ? '添加新主题':'修改主题'" :visible.sync="dialogFormVisibleTheme" width="95%" :close-on-click-modal="false" style="text-align: left">
    <el-form :model="form">
      <el-form-item label="主题名：">
        <el-input
          placeholder="请输入主题名"
          v-model="form.theme"
          clearable>
        </el-input>
      </el-form-item>
      <el-form-item label="作者：">
        <el-input
          placeholder="请输入作者"
          v-model="form.autor"
          clearable>
        </el-input>
      </el-form-item>
      <el-form-item label="主标题：">
        <el-input
          placeholder="请输入主标题"
          v-model="form.title"
          clearable>
        </el-input>
      </el-form-item>
      <el-form-item label="备案号：">
        <el-input
          placeholder="请输入备案号"
          v-model="form.record"
          clearable>
        </el-input>
      </el-form-item>
    </el-form>
    <div style="margin-top: 20px;text-align: right">
      <button class="cancelcss" @click="dialogFormVisibleTheme = false">取 消</button>
      <button class="logincss" @click="SubmitArticles">提 交</button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  name: "ThemeModules",
  data(){
    return{
      dialogFormVisibleTheme: false,
      themeid: 0,
      form:{
        theme: '',
        autor: '',
        title: '',
        record: ''
      }
    }
  },
  methods:{
    showTheme(data){
      if(data == 0){
        this.themeid = 0
        this.form.theme = ''
        this.form.autor = ''
        this.form.title = ''
        this.form.record = ''
      }else{
        this.themeid = data
        this.axios.post(this.Global.BASE_URL+'/Theme/getThemesData',{I:data}).then((res)=>{
          if("2000" == res.data.msg){
            this.form.theme = res.data.data.basicsname
            this.form.autor = res.data.data.author
            this.form.title = res.data.data.mainTitle
            this.form.record = res.data.data.record
          }
          else this.$CustomMessage_ERROR('主题','主题回填错误！');
        }).catch(erroe=>{
          this.$CustomMessage_ERROR('主题','主题错误！');
        })
      }
      this.dialogFormVisibleTheme = true;
    },
    SubmitArticles(){
      let T = this.form.theme,
        A = this.form.autor,
        L = this.form.title,
        R = this.form.record,
        I = this.themeid
      this.axios.post(this.Global.BASE_URL+'/Theme/InsertThemes',
        {T:T,A:A,L:L,R:R,I:I}).then((res)=>{
        if("2000" == res.data.msg){
          this.$parent.ThisThemeReload()
          this.$CustomMessage_OK('主题','添加主题完成！')
          this.dialogFormVisibleTheme = false
        }
        else this.$CustomMessage_ERROR('主题','主题回填错误！');
      }).catch(erroe=>{
        this.$CustomMessage_ERROR('主题','主题错误！');
      })
    }
  }
}
</script>

<style scoped>
.cancelcss{
  border: 1px solid #e5e9f2;
  border-radius: 7px;
  padding: 10px 15px;
  outline: none;
}
.logincss{
  border: 1px solid #e5e9f2;
  border-radius: 7px;
  padding: 10px 15px;
  background: #409EFF;
  color: white;
  outline: none;
}
</style>
